﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Formboard
{

    public class crossPics:PictureBox
    {
        public Image mouseOver;
        public Image mouseClicked;
        bool pawnInPlace;
        int row, column;
        public crossPics(int ro, int col)
        {

            row = ro;
            column = col;
            mouseOver = Properties.Resources.over;
            mouseClicked = Properties.Resources.wstone;
            this.Image = null;
            this.Size = new Size(50, 50);
            int posx = 66 + col * 52; 
            int posy = 68 + ro * 52;
            this.Location = new Point(posx, posy);
            this.BackColor = System.Drawing.Color.Transparent;
            pawnInPlace = false;
        }

        protected override void OnMouseEnter(System.EventArgs e)
        {
            if (!pawnInPlace)
                this.Image = mouseOver;
        }

        protected override void OnMouseLeave(System.EventArgs e)
        {
            if (!pawnInPlace)
                this.Image = null ;
        }

        protected override void OnClick(System.EventArgs e)
        { 
      /*      //if pawn position is ok (locally)
            if ()
            {
                this.Image = mouseClicked; 
                pawnInPlace = true;
                //send informations to server and check return value

                //if server is ok too (returns 204)
                if ()
                {

                    //update board with the other player's turn

                }
                else
                {
                    this.Image = null; 
                    pawnInPlace = false;
                }
            }*/
        }

    }
}
